#include <iostream>
using namespace std;

char s[510][510];
int dp[510][510];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> s[i] + 1;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            if (s[i][j] == 'l') dp[i][j] = 4;
            if (s[i][j] == 'o') dp[i][j] = 3;
            if (s[i][j] == 'v') dp[i][j] = 2;
            if (s[i][j] == 'e') dp[i][j] = 1;
        }

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            dp[i][j] = max(dp[i - 1][j] + dp[i][j], dp[i][j - 1] + dp[i][j]);
    cout << dp[n][m] << endl;

    return 0;
}